package com.gx.smart.building.ui.home.activity;

import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.navigation.Navigation;

import com.gx.smart.base.BaseMVVMActivity;
import com.gx.smart.building.R;
import com.gx.smart.building.databinding.ActivityMainBinding;
import com.gx.smart.building.ui.home.viewmodel.MainViewModel;
import com.gx.smart.building.ui.photo.loader.CustomImageLoader;
import com.previewlibrary.ZoomMediaLoader;

public class MainActivity extends BaseMVVMActivity<ActivityMainBinding, MainViewModel> {


    @Override
    protected Class<MainViewModel> onBindViewModel() {
        return MainViewModel.class;
    }

    @Override
    protected ActivityMainBinding onBindViewBinding(@NonNull LayoutInflater inflater) {
        return DataBindingUtil.setContentView(this, R.layout.activity_main);
    }


    @Override
    protected void initView() {
        ZoomMediaLoader.getInstance().init(new CustomImageLoader());
        binding.bottomNavigationBar.setOnNavigationItemSelectedListener(
                item -> {
                    switch (item.getItemId()) {
                        case R.id.action_home:
                            Navigation.findNavController(
                                    MainActivity.this,
                                    R.id.navHostFragmentEnter
                            ).navigate(R.id.action_global_homeFragment);
                            item.setChecked(true);
                            break;
                        case R.id.action_settings:
                            Navigation.findNavController(
                                    MainActivity.this,
                                    R.id.navHostFragmentEnter
                            ).navigate(R.id.action_global_mineFragment);
                            item.setChecked(true);
                            break;
                    }
                    return false;
                });
    }

}